.
<%-- 
    Document   : logmanagement
    Created on : 13/06/2011, 10:45:31 ص
    Author     : Mostafa
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript">
            var xmlhttp;
            function search()
            {
                var searchtext=document.getElementById("stext").value;
                var divresult=document.getElementById("logdiv");
                divresult.innerHTML="";
                
                
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
               
                xmlhttp.onreadystatechange=handleRequest;
                xmlhttp.open("GET","search.do?searchtext=" + searchtext,true);
                xmlhttp.send();
            
            
            }
            function handleRequest(){
                if(xmlhttp.readyState==4){
                    var divresult=document.getElementById("result");
                    var get=xmlhttp.responseText;
                    var result=get.split(",");
                    var ret="";            
                    if(get[0]==" ")
                    { 
                  
                        ret="";
                 
                     
                    }
                    else{  
                  
                        ret+="<select id=\"providers\" style=\"width:165px\" onchange=\"change()\" name=\"providername\" multiple=\"true\" > ";
                
                        for (i = 0; i < result.length; i++) {
                    
                            ret+="<option value=\""+result[i]+"\" >  "+result[i]+" </option> ";
                        }
                        ret+="</select>  ";
                
                    }
                    divresult.innerHTML=ret;
                }
            }
            
            function change(){
                var owner = document.getElementById("providers").value;
             
                xmlhttp.onreadystatechange=handlechange;
                xmlhttp.open("GET","plogs.do?owner=" + owner,true);
                xmlhttp.send();
                
            }
            
            function handlechange()
            {
                
                if(xmlhttp.readyState==4){
                    var divresult=document.getElementById("logdiv");
                    divresult.innerHTML=xmlhttp.responseText;
                }
                
            }
        </script>
    </head>
    <body>
        <html:form action="/search.do">

            Search Provider : <html:text  property="searchtext" styleId="stext" onkeyup="search()" /> <br>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp; &nbsp;

            <span id="result"></span>

            <div id="logdiv"></div>
        </html:form>
    </body>
</html>
